<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
  <script type="text/javascript">
      var ctrLoanContTable;
  </script>
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <!-- 当前位置 begin -->
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">普通贷款合同</li>
            </ol>
          </div>
        </div>
        <!-- 当前位置 end -->

        <!-- 查询筛选内容 bagin -->
        <div class="row h-main-search">
          <form action="javascript:;" method="post">

            <div class="col-md-1 text-right">
              <label class="control-labe h-form-label" for="form-field-1">客户名称：</label>
            </div>
            <div class="col-md-2">
              <input class="form-control" id="cusName" name="cusName" type="text" value="">
            </div>
            <div class="col-md-1 text-right">
              <label class="control-labe h-form-label" for="form-field-1">证件类型：</label>
            </div>
            <!--
            <div class="col-md-2"  dict="loginType" dicType='select' id="loginTypeGroup">

                          </div>
                           -->
            <div class="col-md-1 text-right">
              <label class="control-labe h-form-label" for="form-field-1">产品名称：</label>
            </div>
            <div class="col-md-2">
              <input class="form-control" id="prdName" name="prdName" type="text" value="">
            </div>
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" onclick="CtrLoanContManager.search()" type="button"><i class="fa fa-search">&nbsp;&nbsp;</i>查询
              </button>
              <a class="btn btn-primary" href="javascript:CtrLoanContManager.addCtrLoanCont()" type="button"><i
                      class="fa fa-plus">&nbsp;&nbsp;</i>新增</a>
              <button class="btn btn-default" type="reset"><i class="fa fa-mail-reply">&nbsp;&nbsp;</i>重置</button>
            </div>
          </form>
        </div>

        <!-- 表格 begin -->
        <div class="panel panel-white h-panel">
          <div class="panel-body">
            <table class="table table-striped table-bordered table-hover text-center" id="ctrLoanCont_table"></table>
          </div>
        </div>
        <!-- 表格 end -->
      </div>
    </div>
    <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->
  <div aria-labelledby="myModalLabel" class="modal fade" id="deleteAttr" role="dialog" tabindex="-1">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <button aria-label="Close" class="close" data-dismiss="modal" type="button"><span
                  aria-hidden="true">&times;</span></button>
          <h4 class="modal-title" id="myModalLabel">删除普通贷款合同信息</h4>
        </div>
        <div class="modal-body">
          <h2 class="modal-title" id="model-title">是否删除此普通贷款合同信息?</h2>
        </div>
        <div class="modal-footer">
          <button class="btn btn-default" data-dismiss="modal" id="modalClose" type="button">关闭</button>
          <button class="btn btn-danger" data-dismiss="modal" id="deleteF" type="button">删除</button>
        </div>
      </div>
    </div>
  </div>
  <!-- 新增 end -->
  <!-- end: SUBVIEW SAMPLE CONTENTS -->


  <!-- modal start -->

  <!-- modal end -->
</div>
<#include "/common/jslib.html">

<script type="text/javascript">
    $(function () {
        CtrLoanContManager = {
            init: function () {
                initDict(DICTURL, INDEX); //初始化数据字典
            },
            search: function () {
                var queryCond = {
                    cusId: $("#cusId").val()
                    , cusName: $("#cusName").val()
                    , prdName: $("#prdName").val()
                };
                ctrLoanContTable.options.queryCond = queryCond;
                var tableId = ctrLoanContTable.options.tableId;
                $(tableId).DataTable().draw();
            },
            addCtrLoanCont: function () {
                window.location.href = "/demo/to-form?operation=add";
            },
            deleteCtrLoanCont: function (url, id) {
                var data = {
                    "contNo": id
                };
                Jmts.deleteItem("确认要删除吗？", url, data, function (result) {
                    if (result.success) {
                        Jmts.succTips("删除成功");
                      CtrLoanContManager.search();
                    }
                });
            },
            formatDetails: function (row, dataId) {
                //根据配置Id 异步查询数据
                var trArr = [];
                for (var j = 0; j < 5; j++) {
                    var sOut = "<tr>";
                    for (var i = 0; i < ctrLoanContTable.options.headerName.length; i++) {
                        if (i != 0) {
                            sOut += '<td>' + j + "-" + i + '</td>';
                        } else {
                            sOut += '<td></td>';
                        }
                    }
                    sOut += '</tr>';
                    trArr.push($(sOut));
                }
                row.child(trArr).show();
            }
        };
        CtrLoanContManager.init();
    });
</script>
<!-- 弹窗下拉 -->
<script type="text/javascript">
    // datatable插件
    (function () {
        // datatable插件
        ctrLoanContTable = new mi.datatable({
            tableId: '#ctrLoanCont_table',
            headerList: [
                '序号',
                '客户编号',
                '客户名称',
                '基准利率',
                '合同金额',
                '申请日期',
                '产品名称'
            ],
            headerName: [
                'tableNo',
                'cusId',
                'cusName',
                'rulingIr',
                'contAmt',
                'aplDate',
                'prdName'
            ],

            ajaxUrl: '/demo/listCtrLoanCont',
            queryCond: function () {

            },
            columnDefs: [
                {
                    //"sWidth": "10%", "aTargets": [ 0 ]
                }
            ],
            dataSrc: function (data) {
                var newArr = [];
                for (var i in data) {
                    var contNo = data[i]['contNo'];
                    var viewDtr = mi.markLink({
                        txt: "<input type='radio' id='ctrLoanCont_select' name='select' value='" + contNo + "'/>",
                        className: 'js-del-row-btn',
                        data: [
                            {contNo: contNo}
                        ]
                    });
                    data[i]['operate'] = viewDtr;
                    data[i]['tableNo'] = Number(i) + 1;
                    var contAmt = data[i]['contAmt'] + "";
                    var rulingIr = data[i]['rulingIr'] + "";
                    data[i]['contAmt'] = Jmts.formatAmt(contAmt);
                    data[i]['rulingIr'] = Jmts.formatRate(rulingIr);
                    var treeData = [
                        {
                            'tableNo': '11',
                            'cusId': "12",
                            'cusName': "13",
                            'certType': "14",
                            'prdCode': "15",
                            'aplDate': "16",
                            'prdName': "17"
                        },
                        {
                            'tableNo': '21',
                            'cusId': "22",
                            'cusName': "23",
                            'certType': "24",
                            'prdCode': "25",
                            'aplDate': "26",
                            'prdName': "27"
                        }
                    ];

                    data[i]["children"] = treeData;

                }
                return data;
            },
            paging: true,
            showTree: true,
            treeView: {
                treeKey: 'contNo',
                treeData: null,
                treeRemote: true,
                ajaxUrl: '/demo/loadCtrLoanCont',
                queryCond: {
                    contNo: '1'
                }
            }
        });

    })();
</script>
</body>
</html>
